home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / Run & Stumpy / source / run.cp < prev    next >
Encoding:
Text File  |  1992-06-19  |  1.5 KB  |  81 lines  |  [TEXT/MPS ]

  1. #define SystemSevenOrLater 1
  2.  
  3. #include <files.h>
  4. #include <aliases.h>
  5. #include <packages.h>
  6. #include <ppctoolbox.h>
  7. #include <folders.h>
  8.  
  9. #include "volumeloop.h"
  10. #include "directoryloop.h"
  11. #include "finderevents.h"
  12. #include "getfoldername.h"
  13.  
  14. #define rootDirID        2
  15.  
  16. static void mountvolumes()
  17.   {
  18.     for ( uint16 refnum=1; 1; refnum++ )
  19.       {
  20.         ParamBlockRec pb;
  21.         pb.volumeParam.ioVRefNum= refnum;
  22.         OSErr error = PBMountVol(&pb);
  23.         if ( error == nsDrvErr || error == paramErr )
  24.             break;
  25.       }
  26.   }
  27.  
  28. static void initsystem()
  29.   {
  30.     InitAllPacks();
  31.     InitGraf(&qd.thePort);
  32.     (void)PPCInit();
  33.   }
  34.  
  35. void main()
  36.   {
  37.     initsystem();
  38.     
  39.     mountvolumes();
  40.     
  41.     Str255 startupfoldername;
  42.     OSErr error = getfoldername( kStartupFolderType, startupfoldername );
  43.     if (error)
  44.         return;
  45.  
  46.     for ( volumeloop vol; vol.unfinished(); vol.next() )
  47.       {
  48.         if (vol.iswrong())
  49.             continue;
  50.         
  51.         FSSpec startupfolder;
  52.         if ( FSMakeFSSpec( vol.refnum(),
  53.                                  rootDirID,
  54.                                  (StringPtr)&startupfoldername,
  55.                                  &startupfolder )
  56.               != noErr )
  57.             continue;
  58.         
  59.         Boolean wasaliased;
  60.         Boolean isfolder;
  61.         if ( ResolveAliasFile( &startupfolder, 1, &isfolder, &wasaliased ) != noErr )
  62.             continue;
  63.         if ( !isfolder )
  64.             continue;
  65.         
  66.         for ( directoryloop entry( startupfolder );
  67.                 entry.unfinished();
  68.                 entry.next() )
  69.           {
  70.             if ( entry.iswrong() || entry.invisible() )
  71.                 continue;
  72.             
  73.             FSSpec item;
  74.             if ( entry.makespec( item ) != noErr )
  75.                 continue;
  76.             
  77.             (void)tellfindertoopen(startupfolder,item);
  78.           }
  79.       }
  80.   }
  81.